package com.xxxx.seckill.VO;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 公共返回对象
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResponseBean {

    private Integer code;
    private String message;
    private Object object;

    /**
     * 成功返回结果
     */
    public static ResponseBean success() {
        return new ResponseBean(ResponseBeanEnum.SUCCESS.getCode(), ResponseBeanEnum.SUCCESS.getMessage(), null);
    }

    /**
     * 成功返回结果
     */
    public static ResponseBean success(Object object) {
        return new ResponseBean(ResponseBeanEnum.SUCCESS.getCode(), ResponseBeanEnum.SUCCESS.getMessage(), object);
    }

    /**
     * 失败返回结果
     */
    public static ResponseBean error(ResponseBeanEnum responseBeanEnum) {
        return new ResponseBean(responseBeanEnum.getCode(), responseBeanEnum.getMessage(), null);
    }

    /**
     * 失败返回结果
     */
    public static ResponseBean error(ResponseBeanEnum responseBeanEnum, Object object) {
        return new ResponseBean(responseBeanEnum.getCode(), responseBeanEnum.getMessage(), object);
    }

}
